import bmp280
from machine import Pin,I2C
import time

i2c = I2C(sda=Pin(4), scl=Pin(5))

def main():
    #初始化BMP280，I2C的sda,scl
    BMP = bmp280.BMP280(i2c)
    
    while True:
        #测量结果
        Tem = BMP.getTemp()
        Pre = BMP.getPress()
        Alt = BMP.getAltitude()
        print("温度：" ,Tem,"℃")
        print("大气压强：" ,Pre,"帕")
        print("海拔高度：" ,Alt,"米")
        time.sleep(2)


if __name__ == "__main__":
    main()
    
    
